﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enterprise.Infrastructure;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.Model.WorkFlow;
using Enterprise.DataFactory;
namespace Enterprise.Data.WorkFlow
{
    /// <summary>
    /// 用户授权审批数据操作
    /// </summary>
    public class UserWfConfigData
    {

        /// <summary>
        ///  数据列表
        /// </summary>
        /// <returns></returns>
        public List<UserWfConfigEntity> UserWfConfigList()
        {
            List<UserWfConfigEntity> list = new List<UserWfConfigEntity>();
            string cmd = "Select * from SYS_USERWFCONFIG";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                UserWfConfigEntity entity = new UserWfConfigEntity();
                if (!Convert.IsDBNull(dr["CID"])) entity.CID = Convert.ToInt32(dr["CID"]);
                if (!Convert.IsDBNull(dr["USERID"])) entity.USERID = Convert.ToInt32(dr["USERID"]);
                if (!Convert.IsDBNull(dr["WFTYPEID"])) entity.WFTYPEID = Convert.ToInt32(dr["WFTYPEID"]);
                if (!Convert.IsDBNull(dr["SQUSERID"])) entity.SQUSERID = Convert.ToInt32(dr["SQUSERID"]);
                if (!Convert.IsDBNull(dr["STARTIME"])) entity.STARTIME = Convert.ToDateTime(dr["STARTIME"]);
                if (!Convert.IsDBNull(dr["ENDTIME"])) entity.ENDTIME = Convert.ToDateTime(dr["ENDTIME"]);
                if (!Convert.IsDBNull(dr["ISUSED"])) entity.ISUSED = Convert.ToInt32(dr["ISUSED"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 流程数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void UserWfConfigExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

        /// <summary>
        /// 返回数据集合
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public DataSet ExcuteDataSet(string cmd)
        {
            return DbExecute.GetDataSet(cmd);
        }

    }
}
